package com.cszjzx.member.action;


import org.apache.struts2.ServletActionContext;
import com.cszjzx.member.po.Master;
import com.cszjzx.member.service.MasterService;
import com.cszjzx.member.service.MasterServiceImpl;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class AdminAction extends ActionSupport{
	private Master master = (Master) ServletActionContext.getRequest().getSession().getAttribute("master");
	private String originalPassword;
	private String newPassword1;
	private String message;
	MasterService masterservice = new MasterServiceImpl(); 

	
	public String getOriginalPassword() {
		return originalPassword;
	}
	public void setOriginalPassword(String originalPassword) {
		this.originalPassword = originalPassword;
	}
	public String getNewPassword1() {
		return newPassword1;
	}
	public void setNewPassword1(String newPassword1) {
		this.newPassword1 = newPassword1;
	}

	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}

	public String modifyPassword(){
		String password = master.getPassword();
		if(!password.equals(originalPassword)){
			message = "原密码输入不正确！";
		}else{
			master.setPassword(newPassword1);
			masterservice.alterPassword(master);
			message ="修改密码成功！";
		}
		return "modifyPassword";
	}
	
	
}
